# 字典
# vowels 4
vowels = ['a','e','i','o','u']
word = input("Provide a word to search for vowels:")
found = {}  #建立空字典
found['a'] = 0  # 初始化
found['e'] = 0
found['i'] = 0
found['o'] = 0
found['u'] = 0
for letter in word:
    if letter in vowels:
        found[letter] +=1 # 指示值递增 统计次数
for k,v in sorted(found.items()): # k对应键;v对应值;sorted按字母顺序组织输出;item返回一个键/值对列表,一次迭代中，会向for循环返回下一个键和它的关联值
    print(k,'was found',v,'time(s).')


# vowels 5
vowels = ['a', 'e', 'i', 'o', 'u']
word = input("Provide a word to search for vowels: ")

found = {}

for letter in word:
    if letter in vowels:
        found[letter] += 1

for k, v in sorted(found.items()):
    print(k, 'was found', v, 'time(s)')



# vowels 6
vowels = ['a','e','i','o','u']
word = input("Provide a word to search for vowels:")
found = {}  #建立空字典
for letter in word:
    if letter in vowels:
        found.setdefault(letter,0) # 保证把一个不存在的键初始化为一个指定的默认值，替换if/if not
        found[letter] +=1 # 指示值递增 统计次数
for k,v in sorted(found.items()): # k对应键;v对应值;sorted按字母顺序组织输出;item返回一个键/值对列表,一次迭代中，会向for循环返回下一个键和它的关联值
    print(k,'was found',v,'time(s).')

# 集合
# vowels 7
vowels = set('aeiou')
word = input("Provide a world to search for vowels:")
found = vowels.intersection(set(word)) # 既在vowels中又在set(word)中 交集
for vowels in found:
    print(vowels)

# pprint模块--美观打印
import pprint
people={}
people['Ford']={'Name':'Ford Prefect',
                'Gender':'Male'}
people['Arthur']={'Name':'Arthur Dent',
                  'Gender':'Male'}
print(people)
pprint.pprint(people)